#include "gamehall.h"
#include "ui_gamehall.h"



GameHall::GameHall(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::GameHall)
{
    ui->setupUi(this);

    this->setFixedSize(QSize(2000,1500));
    this->setWindowIcon(QIcon(":/res/ico.png"));
    this->setWindowTitle("GreedySnake game");
    //QSound::play(":/res/background_sound.wav");

//    thread=new Thread;
//    thread->start();
    //loopSound();
    Anime_name();
}

GameHall::~GameHall()
{
    delete ui;
}


void GameHall::paintEvent(QPaintEvent *event)
{
    (void)event;
    QPainter painter(this);

    QPixmap pix(":/res/GameHall.png");

    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}

void GameHall::on_start_clicked()
{
    GameSelect *select=new GameSelect;
    this->close();
    select->setGeometry(this->geometry());
    select->show();
}

void GameHall::on_quit_clicked()
{
    this->close();
}

void GameHall::Anime_name()
{
    QPropertyAnimation *Anima = new QPropertyAnimation(ui->name, "pos");
    Anima ->setDuration(600);
    Anima->setStartValue(QPoint(0,150));
    Anima->setEndValue(QPoint(300,150));
    Anima->setEasingCurve(QEasingCurve::InOutCubic);
    Anima ->start();
}

//void GameHall::loopSound()
//{
//    QSoundEffect *effect = new QSoundEffect(this);
//    effect->setSource(QUrl::fromLocalFile(":/res/background_sound.wav"));
//    effect->setLoopCount(QSoundEffect::Infinite); // 无限次循环播放
//    effect->play();
//}
